import 'package:flutter_juwo/common/common_index.dart';
import 'package:flutter/material.dart';
import 'package:flutter_juwo/ui/utils/utils.dart';

///************************
/// @auther nb
/// @function 待返
/// @创建日期 2019/8/12 14:35
///************************
class WaitReturn extends StatefulWidget {
  @override
  _WaitReturnState createState() => _WaitReturnState();
}

class _WaitReturnState extends State<WaitReturn> {
  List datas = [
    {
      "time": "2019.05.21 10:14",
      "status": "进行中",
      "num": "157879415131",
      "goodsName": "连衣裙 演出服",
      "waite": "179.88",
      "return": "79.88"
    },
    {
      "time": "2019.05.21 10:14",
      "status": "进行中",
      "num": "157879415131",
      "goodsName": "连衣裙 演出服",
      "waite": "179.88",
      "return": "79.88"
    },
    {
      "time": "2019.05.21 10:14",
      "status": "进行中",
      "num": "157879415131",
      "goodsName": "连衣裙 演出服",
      "waite": "179.88",
      "return": "79.88"
    }
  ];

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colours.c243,
      appBar: UiUtils.appBar(context, "待返明细"),
      body: Column(
        children: <Widget>[
          UiUtils.dividerWidget(1),
          getTop(),
          Expanded(
            flex: 1,
            child: EasyRefresh(
                onRefresh: () {},
                onLoad: () {},
                child: ListView.builder(
                    itemCount: datas.length,
                    itemBuilder: (BuildContext context, int index) {
                      return getItem(datas[index]);
                    })),
          )
        ],
      ),
    );
  }

  getTop() {
    return Container(
      height: ScreenUtil().setWidth(252),
      child: Stack(
        children: <Widget>[
          Container(
            color: Colors.white,
            padding: EdgeInsets.fromLTRB(
                ScreenUtil().setWidth(30),
                ScreenUtil().setWidth(40),
                ScreenUtil().setWidth(30),
                ScreenUtil().setWidth(22)),
            child: Image.asset(Utils.getImgPath("bg_wait_return")),
          ),
          Container(
            padding: EdgeInsets.fromLTRB(
                ScreenUtil().setWidth(90),
                ScreenUtil().setWidth(80),
                ScreenUtil().setWidth(30),
                ScreenUtil().setWidth(22)),
            child: Row(
              children: <Widget>[
                Expanded(
                  flex: 1,
                  child: Column(
                    crossAxisAlignment: CrossAxisAlignment.start,
                    children: <Widget>[
                      Container(
                        child: Text(
                          "1032.14",
                          style: TextStyles.custom(
                              42, Colors.white, Font.PingFangBlod),
                        ),
                      ),
                      Container(
                        margin: EdgeInsets.only(top: ScreenUtil().setWidth(20)),
                        child: Text(
                          "待返本金",
                          style: TextStyles.custom(
                              24, Colors.white, Font.PingFangBlod),
                        ),
                      )
                    ],
                  ),
                ),
                Expanded(
                  flex: 1,
                  child: Container(
                    margin: EdgeInsets.only(left: ScreenUtil().setWidth(60)),
                    child: Column(
                      crossAxisAlignment: CrossAxisAlignment.start,
                      children: <Widget>[
                        Container(
                          child: Text(
                            "34.55",
                            style: TextStyles.custom(
                                42, Colors.white, Font.PingFangBlod),
                          ),
                        ),
                        Container(
                          margin:
                              EdgeInsets.only(top: ScreenUtil().setWidth(20)),
                          child: Text(
                            "待返佣金",
                            style: TextStyles.custom(
                                24, Colors.white, Font.PingFangBlod),
                          ),
                        )
                      ],
                    ),
                  ),
                )
              ],
            ),
          )
        ],
      ),
    );
  }

  Widget getItem(data) {
    return Container(
      height: ScreenUtil().setWidth(322),
      margin: EdgeInsets.fromLTRB(ScreenUtil().setWidth(30),
          ScreenUtil().setWidth(30), ScreenUtil().setWidth(30), 0),
      decoration: BoxDecoration(
        color: Colors.white,
        borderRadius: BorderRadius.circular(5),
      ),
      child: Container(
        child: Column(
          children: <Widget>[
            Container(
              margin: EdgeInsets.only(
                  left: ScreenUtil().setWidth(30),
                  top: ScreenUtil().setWidth(30),
                  right: ScreenUtil().setWidth(30)),
              child: Row(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: <Widget>[
                  Text(
                    "${data["time"]}",
                    style: TextStyles.custom(
                        24, Color(0xFF999999), Font.PingFangMedium),
                  ),
                  Text(
                    "${data["status"]}",
                    style: TextStyles.custom(
                        24, Color(0xFF508cff), Font.PingFangMedium),
                  )
                ],
              ),
            ),
            Container(
              margin: EdgeInsets.only(
                  left: ScreenUtil().setWidth(30),
                  top: ScreenUtil().setWidth(34),
                  right: ScreenUtil().setWidth(30)),
              child: Row(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: <Widget>[
                  Text(
                    "订单编号",
                    style: TextStyles.custom(
                        24, Color(0xFF666666), Font.PingFangMedium),
                  ),
                  Text(
                    "${data["num"]}",
                    style: TextStyles.custom(
                        24, Color(0xFF666666), Font.PingFangMedium),
                  )
                ],
              ),
            ),
            Container(
              margin: EdgeInsets.only(
                  left: ScreenUtil().setWidth(30),
                  top: ScreenUtil().setWidth(22),
                  right: ScreenUtil().setWidth(30)),
              child: Row(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: <Widget>[
                  Text(
                    "商品名称",
                    style: TextStyles.custom(
                        24, Color(0xFF666666), Font.PingFangMedium),
                  ),
                  Text(
                    "${data["goodsName"]}",
                    style: TextStyles.custom(
                        24, Color(0xFF666666), Font.PingFangMedium),
                  )
                ],
              ),
            ),
            Container(
              margin: EdgeInsets.only(
                  left: ScreenUtil().setWidth(30),
                  top: ScreenUtil().setWidth(20)),
              child: UiUtils.dividerWidget(1),
            ),
            Container(
              margin: EdgeInsets.only(
                  left: ScreenUtil().setWidth(30),
                  top: ScreenUtil().setWidth(24),
                  right: ScreenUtil().setWidth(30)),
              child: Row(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                crossAxisAlignment: CrossAxisAlignment.start,
                children: <Widget>[
                  Text(
                    "共计",
                    style: TextStyles.custom(
                        24, Color(0xFF666666), Font.PingFangMedium),
                  ),
                  Column(
                    children: <Widget>[
                      Container(
                        width: ScreenUtil().setWidth(200),
                        child: Row(
                          mainAxisAlignment: MainAxisAlignment.spaceBetween,
                          children: <Widget>[
                            Container(
                              child: Text(
                                "待返",
                                style: TextStyles.custom(24, Color(0xFF999999),
                                    Font.PingFangMedium),
                              ),
                            ),
                            Container(
                              child: Text("${data["waite"]}元",
                                  style: TextStyles.custom(
                                      24,
                                      Color(0xFFe61f1c),
                                      Font.PingFangMedium)),
                            )
                          ],
                        ),
                      ),
                      Container(
                        margin: EdgeInsets.only(top: ScreenUtil().setWidth(10)),
                        width: ScreenUtil().setWidth(200),
                        child: Row(
                          mainAxisAlignment: MainAxisAlignment.spaceBetween,
                          children: <Widget>[
                            Container(
                              child: Text("已返",
                                  style: TextStyles.custom(
                                      24,
                                      Color(0xFF999999),
                                      Font.PingFangMedium)),
                            ),
                            Container(
                              child: Text("${data["return"]}元",
                                  style: TextStyles.custom(
                                      24,
                                      Color(0xFFe61f1c),
                                      Font.PingFangMedium)),
                            )
                          ],
                        ),
                      ),
                    ],
                  )
                ],
              ),
            ),

            /*
                  *    "time": "2019.05.21 10:14",
      "status": "进行中",
      "num": "157879415131",
      "goodsName": "连衣裙 演出服",
      "waite": "179.88",
      "return": "79.88"
                  * */
          ],
        ),
      ),
    );
  }

}
